package com.fss.daoTestCases;

import java.util.Date;
import java.util.List;

import junit.framework.TestCase;

import com.fss.user.dao.UserDaoImpl;
import com.fssDataModels.*;
import com.fss.activity.dao.ActivityDaoImpl;;

public class TestActivityDaoImpl extends TestCase{
	public TestActivityDaoImpl(
	        String name) {
	        super(name);
	    }
	
	private UserDaoImpl db = new UserDaoImpl();//connection to database
	private ActivityDaoImpl db2 =  new ActivityDaoImpl();
	
		/*========test right-data cases:============================*/		 
	    public void testInsert() {
	    	
	    	
	    	TbUser author = db.getUser("fss_admin1");
	    	
	    	TbActivity newActivity = new TbActivity(author,"dummy activity ","dummy content",new Date());
	        
	    	assertEquals(1, db2.insertActivity(newActivity));	
	    	
	    	    	
	    	db2.deleteActivity(newActivity);
	        
	        
	        
	    }
	    
	    public void testUpdate() {
	    	TbUser author = db.getUser("fss_admin1");
	    	
	    	TbActivity newActivity = new TbActivity(author,"dummy activity ","dummy content",new Date());
	        
	    	db2.insertActivity(newActivity);
	    	
	    	newActivity.setContent("asiajinzai");
	    	
	    	
	    	assertEquals(1,db2.updateActivity(newActivity));
	    	
	    	db2.deleteActivity(newActivity);
	    	
	    	
	    }
	    
	    public void testDelete() {
	    	TbUser author = db.getUser("fss_admin1");
	    	
	    	TbActivity newActivity = new TbActivity(author,"delete activity ","dummy content",new Date());
	        
	    	db2.insertActivity(newActivity);
	    	
	    	assertEquals(1,db2.deleteActivity(newActivity));
	        	       
	    }
	    
	    /*============test wrong-data cases:==========================*/
	    
	    
	    
	    /*=================entry point of the testing program===========================*/
	    public static void main(String[] args) {
	        junit.textui.TestRunner.run(
	        		TestActivityDaoImpl.class);
	    }
}
